package com.wyl.studyjavaxvalidation.controller;

import com.wyl.studyjavaxvalidation.dto.PersonDto;
import com.wyl.studyjavaxvalidation.util.ValidList;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author 吴宇亮 on 2021/12/20 11:31
 */
@RestController
@RequestMapping("/student")
public class StudentController {

    @PostMapping("/add")
    public String add(@RequestBody @Valid PersonDto personDto){
        System.out.println(personDto);
        return personDto.toString();
    }

    // valid对List这种不生效：https://blog.csdn.net/onceing/article/details/110119877
    @PostMapping("/addList")
    public String add(@RequestBody @Valid ValidList<PersonDto> personDtoList){
        System.out.println(personDtoList);
        return personDtoList.toString();
    }

}
